package com.lanou.myapp.imageloader;

import android.app.Application;
import android.content.Context;
import android.util.Log;
import android.widget.TextView;

import com.lanou.myapp.greendao.DaoMaster;
import com.lanou.myapp.greendao.DaoSession;

import cn.jpush.android.api.JPushInterface;

/**
 * Created by dllo on 15/10/21.
 */
public class BaseApplication extends Application{
    private static Context context;

    private static DaoSession daoSession;
    private static DaoMaster daoMaster;


    public static DaoMaster getDaoMaster() {
        if (daoMaster == null){
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(context,"comicHome.db",null);
            daoMaster = new DaoMaster(helper.getWritableDatabase());
        }
        daoSession = daoMaster.newSession();

        return daoMaster;
    }

    public static DaoSession getDaoSession() {
        if (daoSession == null){
            daoMaster = getDaoMaster();
            daoSession = daoMaster.newSession();
        }
        return daoSession;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        context = this;
        JPushInterface.init(this);

        JPushInterface.setDebugMode(true);

    }

    public static Context getContext() {
        return context;
    }


}
